Skip to content

Integrate predictionengine into the workflows#588

Merged
chrisaddy merged 1 commit into06-02-fix_inter-service_communication_patternsfrom
06-04-integrate_predictionengine_into_the_workflows
Jun 5, 2025
Merged

Integrate predictionengine into the workflows#588
chrisaddy merged 1 commit into06-02-fix_inter-service_communication_patternsfrom
06-04-integrate_predictionengine_into_the_workflows

Conversation

@forstmeier
Copy link
Copy Markdown
Collaborator

@forstmeier forstmeier commented Jun 5, 2025

Overview

Changes

  • initial predictionengine resource integration into model training Flyte workflow
  • various linting fixes

Comments

There are a bunch of linting fixes in this PR so I'm sure there will be some merge conflicts and rebasing in the future. Also, I haven't tested this yet.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 5, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Collaborator Author

forstmeier commented Jun 5, 2025

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@graphite-app
Copy link
Copy Markdown

graphite-app Bot commented Jun 5, 2025

Graphite Automations

"Assign author to pull request" took an action on this PR • (06/05/25)

1 assignee was added to this PR based on John Forstmeier's automation.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Integrate the prediction engine into the broader workflows by updating type hints, standardizing randomness in tests, and cleaning up import and exception patterns.

  • Migrated all typing.* imports to built-in generic types (e.g. dict[str, ...], list[...]).
  • Replaced np.random.randn with np.random.default_rng().standard_normal in tests for consistency.
  • Refactored exception raise statements to assign message variables (enabling lint suppression) and reorganized imports.

Reviewed Changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
application/predictionengine/tests/test_multi_head_self_attention.py Switched to default_rng and added # noqa comments on assertions
application/predictionengine/src/predictionengine/multi_head_self_attention.py Updated type hints to built-in generics; refactored cast usage
application/predictionengine/src/predictionengine/post_processor.py Migrated typing generics to built-ins; standardized exception messages
application/predictionengine/src/predictionengine/miniature_temporal_fusion_transformer.py Renamed parameters and updated method signatures; reorganized imports
application/predictionengine/src/predictionengine/main.py Introduced SEQUENCE_LENGTH; parameterized hard-coded values; updated route decorator
Comments suppressed due to low confidence (1)

application/predictionengine/src/predictionengine/main.py:94

  • Removing response_model=PredictionResponse from this route decorator may lead to missing automatic response validation and documentation. Re-add response_model=PredictionResponse if you rely on FastAPI's schema enforcement.
@application.post("/create-predictions")

)

attention_weights: Tensor = cast(Tensor, attention_scores).softmax(axis=-1)
attention_weights: Tensor = cast("Tensor", attention_scores).softmax(axis=-1)
Copy link

Copilot AI Jun 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typing.cast expects a type object rather than a string literal. Update to cast(Tensor, attention_scores) to ensure the intended type cast for static analysis.

Suggested change
attention_weights: Tensor = cast("Tensor", attention_scores).softmax(axis=-1)
attention_weights: Tensor = cast(Tensor, attention_scores).softmax(axis=-1)

Copilot uses AI. Check for mistakes.
Comment on lines +23 to +26
error = cast("Tensor", y_true - y_pred)
for quantile in quantiles:
quantile_error = cast(Tensor, quantile * error)
quantile_minus_one_error = cast(Tensor, (quantile - 1) * error)
quantile_error = cast("Tensor", quantile * error)
quantile_minus_one_error = cast("Tensor", (quantile - 1) * error)
Copy link

Copilot AI Jun 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first argument to typing.cast must be a type, not a string. Change to cast(Tensor, y_true - y_pred) for correct type annotation.

Copilot uses AI. Check for mistakes.
residual = features

gated_output = cast(Tensor, gate_state * output_state + residual)
gated_output = cast("Tensor", gate_state * output_state + residual)
Copy link

Copilot AI Jun 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typing.cast should be passed the Tensor class, not a string. Use cast(Tensor, gate_state * output_state + residual) so type checkers recognize the cast.

Suggested change
gated_output = cast("Tensor", gate_state * output_state + residual)
gated_output = cast(Tensor, gate_state * output_state + residual)

Copilot uses AI. Check for mistakes.
except Exception as e:
except Exception as e: # noqa: BLE001
logger.warning(f"Failed to load model weights: {e}")
logger.warning(f"Failed to load model weights: {e}")
Copy link

Copilot AI Jun 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] This logger.warning is duplicated immediately after the newly added one. Consider removing one to avoid redundant log entries.

Suggested change
logger.warning(f"Failed to load model weights: {e}")

Copilot uses AI. Check for mistakes.
@chrisaddy chrisaddy merged commit 49b392f into 06-02-fix_inter-service_communication_patterns Jun 5, 2025
5 of 6 checks passed
@forstmeier forstmeier deleted the 06-04-integrate_predictionengine_into_the_workflows branch June 5, 2025 01:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants